import Flutter
import UIKit

@main
@objc class AppDelegate: FlutterAppDelegate {
  
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    
    // 初始化NativeBridge
    if let controller = window?.rootViewController as? FlutterViewController {
      NativeBridge.shared.initialize(controller: controller)
    }
    
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
  
  override func applicationWillTerminate(_ application: UIApplication) {
    // 释放NativeBridge资源
    NativeBridge.shared.dispose()
    super.applicationWillTerminate(application)
  }
}
